package com.wch.SpringBootTestDemo.activemq;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.jms.Destination;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

@Service("jmsProducter")
public class JMSProducter {

	private Logger logger = LoggerFactory.getLogger(JMSProducter.class);
	
	@Autowired
	private JmsTemplate jmsTemplate;
	
	/**
	 * 发送消息
	 * @param destination  发送到的队列
	 * @param message   待发送的消息
	 */
	public void converAndSend(Destination destination,String message){
		jmsTemplate.convertAndSend(destination, message);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		logger.info(df.format(new Date())+":消息发送成功");
	}
}
